package com.tsky.yyj.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.tsky.casing.action.BackAction;
import com.tsky.common.ActionUtil;
import com.tsky.system.entity.Constant;
import com.tsky.yyj.entity.Area;
import com.tsky.yyj.entity.Classify;
import com.tsky.yyj.entity.Seller;
import com.tsky.yyj.json.YYJJsonFormat;
import com.tsky.yyj.manager.BaseManager;

@Component("getAction")
@Scope("prototype")
public class GetAction extends BackAction {
	@Autowired
	private BaseManager entityManager;

	/* bean properties */
	private String initid;
	private String sellerid;
	private String cityid;
	private String areaid;

	public void getTypes(){
		List<?> list = entityManager.getAllEntityByField(Classify.class, "property", "1");
		Object json = YYJJsonFormat.typesToJson(list, initid);
		ActionUtil.ajaxWrite(json);
	}
	
	public void getSellers(){
		List<?> list = entityManager.getAllEntity(Seller.class);
		Object json = YYJJsonFormat.sellersToJson(list, sellerid);
		ActionUtil.ajaxWrite(json);
	}
	
	public void getCitys(){
		List<?> list = entityManager.getAllEntityByField(Constant.class, "fieldName", "cityType");
		Object json = YYJJsonFormat.citysToJson(list, cityid);
		ActionUtil.ajaxWrite(json);
	}
	
	public void getAreas(){
		List<?> list = entityManager.getAllEntityByField(Area.class, "city.id", cityid);
		Object json = YYJJsonFormat.areasToJson(list, areaid);
		ActionUtil.ajaxWrite(json);
	}
	
	public BaseManager getEntityManager() {
		return entityManager;
	}

	public void setEntityManager(BaseManager entityManager) {
		this.entityManager = entityManager;
	}

	public String getInitid() {
		return initid;
	}

	public void setInitid(String initid) {
		this.initid = initid;
	}

	public String getSellerid() {
		return sellerid;
	}

	public void setSellerid(String sellerid) {
		this.sellerid = sellerid;
	}

	public String getCityid() {
		return cityid;
	}

	public void setCityid(String cityid) {
		this.cityid = cityid;
	}

	public String getAreaid() {
		return areaid;
	}

	public void setAreaid(String areaid) {
		this.areaid = areaid;
	}

}
